const a = [1, undefined, , 3];
let s = "";
// 跳过空元素
a.forEach((v, i) => (s += `(${i}: ${v})`));
console.log(s); // (0: 1)(1: undefined)(3: 3)
// 跳过空元素的执行
console.log(a.map((v, i) => `(${i}, ${v})`)); // [ '(0, 1)', '(1, undefined)', <1 empty item>, '(3, 3)' ]
console.log(a.filter((v) => true)); // [ 1, undefined, 3 ]
console.log(a.find((v) => v % 2 === 1)); // 1
console.log(a.findIndex((v) => v % 2 === 1)); // 0
console.log(a.every((v) => v % 2 === 1)); // false
console.log(a.some((v) => v % 2 === 1)); // true
console.log(a.reduce((r, v) => r + (v ?? 0), 100)); // 104
console.log(a.reduceRight((r, v) => r + (v ?? 0), 100)); // 104
